package workshopdesign.Model;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Dom
 */
public class Loan implements Serializable {

    public enum State {

        borrowed, expired, returned
    };
    private long id;
    private Date borrowDate;
    private int period;
    private State state;
    private long copy_id;
    private long person_id;

    public Loan(long id, long person_id, long copy_id, Date borrowDate, int period, State state) {
        this.id = id;
        this.person_id = person_id;
        this.copy_id = copy_id;
        this.borrowDate = borrowDate;
        this.period = period;
        this.state = state;
    }

    public long getId() {
        return id;
    }

    public State getState() {
        return state;
    }

    public void setState(State intState) {
        state = intState;
    }

    public Date getBorrowDate() {
        return borrowDate;
    }

    public void setBorrowDate(Date intDate) {
        borrowDate = intDate;
    }

    public int getPeriod() {
        return period;
    }

    public void setPeriod(int Period) {
        period = Period;
    }

    public long getCopyId() {
        return copy_id;
    }

    public long getPersonId() {
        return person_id;
    }

    public Date getExprationDate(){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(borrowDate);
        calendar.add(Calendar.DAY_OF_YEAR, period);
        return calendar.getTime();
    }
}
